import { post, get, Delete, exportXlsx } from "../utlis/http.js"
import i18n from '../assets/language/index.js'
export const configure = {


  //新增物料信息
  createMaterial (param, type) {

    if (type == "新增物料信息") {
      return post(`/item/add`, param)
    } else {
      return post(`/item/modify`, param)  //修发物料信息
    }
  },
  //查询物料列表
  getItemList (param) {
    if (param.field) {
      return post(`/item/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/item/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  //删除物料列表
  removeItem (id) {
    return post('/item/remove', { fid: id })
  },
  //新增类信息
  createItemClass (param, type) {
    if (type == i18n.t('dialog.mater_cls_add')) {
      return post(`/itemClass/add`, param)
    } else {
      return post(`/itemClass/modify`, param)  //修改类信息
    }
  },
  //获取物料定义列表接口
  getItemClassList (param) {
    if (param.field) {
      return post(`/itemClass/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/itemClass/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  // 删除配方
  removeItemClass (id) {
    return post('/itemClass/remove', { fid: id })
  },


  //新增类信息
  createItemInvClass (param, type) {
    if (type == i18n.t('third.itemiv_add')) {
      return post(`/itemInv/add`, param)
    } else {
      return post(`/itemInv/modify`, param)  //修改类信息
    }
  },
  //获取物料定义列表接口
  getItemInvList (param) {
    if (param.field) {
      return post(`/itemInv/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/itemInv/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  // 删除配方
  removeitemInv (id) {
    return post('/itemInv/remove', { fid: id })
  },

  //新增单位信息
  createUomInfo (param, type) {
    if (type == i18n.t('dialog.add_meter')) {
      return post(`/uom/add`, param)
    } else {
      return post(`/uom/modify`, param)  //修改计量单位
    }
  },
  //获取计量单位列表
  getUomList (param) {
    if (param.field) {
      return post(`/uom/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/uom/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  //删除计量单位
  removeUom (id) {
    return post('/uom/remove', { fid: id })
    // return Delete(`/uom/remove/${id}`)
  },
  //新增设备类型定义
  equipmentClassAdd (param, type) {
    if (type == i18n.t('dialog.equip_cls_add')) {
      return post(`/equipmentClass/add`, param)
    } else {
      return post(`/equipmentClass/modify`, param)  //修改设备类型定义
    }
  },
  // 查询设备类型列表
  getEquipmentClassList (param) {
    if (param.field) {
      return post(`/equipmentClass/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/equipmentClass/list?page=${param.page}&size=${param.size}`, param)
    }
  },
  //根据设备组查询设备类型
  getEqpClsByTrainId (id) {
    return get(`/equipmentClass/getByTrainId/${id}`)
  },
  //删除设备类型列表
  removeEquipment (id) {
    return Delete(`/equipmentClass/remove/${id}`)
  },
  //查询设备列表
  getEquipmentList (param) {
    if (param.field) {
      return post(`/equipment/list?page=${param.page}&size=${param.size}&sort=${param.field ? param.field : 'fLastModifyTime'},${param.order ? param.order : 'desc'}`, param)
    } else {
      return post(`/equipment/list?page=${param.page}&size=${param.size}&sort=fLastModifyTime,desc`, param)
    }

  },
  // 新增设备定义
  equipmentAdd (param, type) {
    if (type == "新增设备定义") {
      return post(`/equipment/add`, param)
    } else {
      return post(`/equipment/modify`, param)  //修改设备类型定义
    }
  },
  //删除设备定义
  removeEquipmentDev (id) {
    return Delete(`/equipment/remove/${id}`)
  },
  //查询当前的设备信息
  findEquipment (id) {
    return get(`/equipment/find/${id}`)
  },
  // 设备校验
  checkEquip () {
    return post(`/equipment/checkEquip`)
  },

  //设备组新增
  createTrainList (param, type) {
    if (type == i18n.t('basic.add_equip_group')) {
      return post(`/train/add`, param)
    } else {
      return post(`/train/modify`, param)  //修改设备组
    }
  },
  //查询设备组列表
  getTrainList (param) {
    return post(`/train/list?page=${param.page}&size=${param.size}`, param)
  },
  //查找当前点击的设备组信息
  findTrainDetali (id) {
    return get(`/train/find/${id}`)
  },
  //删除设备组
  deleteTrain (id) {
    return Delete(`/train/remove/${id}`)
  },
  //添加设备组子设备
  trainEquipLinkAdd (param, type) {
    if (type == i18n.t('common.add')) {
      return post(`/trainEquipLink/add`, param)
    } else {
      return post(`/trainEquipLink/modify`, param)  //修改设备组
    }
  },
  // 查询设备组子设备列表
  getTrainEquipLinkList (param) {
    if (param.field) {
      return post(`/trainEquipLink/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/trainEquipLink/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  //查询子设备详情
  findTrainEquipLink (id) {
    return get(`/trainEquipLink/find/${id}`)
  },
  //删除设备组子设备
  deleteTrainEquipLink (id) {
    return Delete(`/trainEquipLink/remove/${id}`)
  },
  // 获得设备类和阶段定义关联关系列表
  getEqpClassPhaseLinkList (param) {
    if (param.field) {
      return post(`/eqpClassPhaseLink/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/eqpClassPhaseLink/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  // 添加设备类和阶段定义关联关系列表
  eqpClassPhaseLinkAdd (param, type) {
    if (type == 1) {
      return post(`/eqpClassPhaseLink/add`, param)
    } else {
      return post(`/eqpClassPhaseLink/modify`, param)
    }
  },
  // 添加设备类和阶段定义关联关系列表
  eqpClassPhaseLinkAdds (param) {
    return post(`/eqpClassPhaseLink/adds`, param)
  },
  //删除设备类和阶段定义关联关系列表
  eqpClassPhaseLinkRemove (id) {
    return Delete(`/eqpClassPhaseLink/remove/${id}`)
  },

  // 获得系统日志存储列表
  getAuditTrailList (param) {
    return post(`/hisAuditTrail/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
  },

  // 获得系统日志 用户列表
  getAuditUserList (param) {
    return post(`/hisAuditTrail/listUser`, param)
  },


  // 获得阶段定义列表
  getPhaseDefineList (param) {
    return post(`/phaseDefine/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
  },
  //新增阶段定义
  phaseDefineAdd (param, type) {
    if (type == 1) {
      return post(`/phaseDefine/add`, param)
    } else {
      return post(`/phaseDefine/modify`, param)  //修改阶段定义
    }
  }, //删除阶段定义
  removePhaseDefine (id) {
    return Delete(`/phaseDefine/remove/${id}`)
  },
  checkPhaseDefine (id) {
    return get(`/phaseDefine/checkInUse/${id}`)
  },

  // 获得阶段单元参数列表
  getUnitPhaseDefineList (param) {
    if (param.field) {
      return post(`/unitPhaseDefine/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/unitPhaseDefine/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  //新增阶段单元参数定义
  unitPhaseDefineAdd (param, type) {
    if (type == 1) {
      return post(`/unitPhaseDefine/add`, param)
    } else {
      return post(`/unitPhaseDefine/modify`, param)  //修改单元参数
    }
  },
  //删除阶段单元参数
  removeUnitPhaseDefine (id) {
    return post(`/unitPhaseDefine/remove/`, { fid: id })
  },
  //获取阶段单元参数
  findUnitPhaseDefine (param) {
    return post(`/unitPhaseDefine/find`, param)
  },


  // 获得单元参数列表
  getUnitTagsDefineList (param) {
    if (param.field) {
      return post(`/unitTagsDefine/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/unitTagsDefine/list?page=${param.page}&size=${param.size}`, param)
    }

  },
  //新增单元参数定义
  unitTagsDefineAdd (param, type) {
    if (type == 1) {
      return post(`/unitTagsDefine/add`, param)
    } else {
      return post(`/unitTagsDefine/modify`, param)  //修改单元参数
    }
  },
  //删除单元参数
  removeUnitTagsDefine (id) {
    return post(`/unitTagsDefine/remove`, { fid: id })
  },
  //获取单元参数
  findUnitTagsDefine (param) {
    return post(`/unitTagsDefine/find`, param)
  },



  // 获得设备类的单元参数列表
  getEquipmentClassTagDefineList (param) {
    if (param.field) {
      return post(`/equipmentClassTagDefine/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/equipmentClassTagDefine/list?page=${param.page}&size=${param.size}`, param)
    }
  },
  //新增设备类的单元参数
  equipmentClassTagDefineAdd (param, type) {
    if (type == i18n.t('dialog.equip_cls_add_argu')) {
      return post(`/equipmentClassTagDefine/add`, param)
    } else {
      //设备类的单元参数
      return post(`/equipmentClassTagDefine/modify`, param)
    }
  }, //删除设备类的单元参数
  removeEquipmentClassTagDefine (id) {
    return post(`/equipmentClassTagDefine/remove`, { fid: id })
  },
  //获取单元参数
  findUnitPhaseTagsDefine (param) {
    return post(`/unitPhaseTagsDefine/find`, param)
  },



  // 获得报表列表
  getCumLinksList (param) {
    if (param.field) {
      return post(`/cumLinks/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/cumLinks/list?page=${param.page}&size=${param.size}`, param)
    }
  },
  //新增报表参数
  cumLinksAdd (param, type) {
    if (type == i18n.t('dialog.report_add')) {
      return post(`/cumLinks/add`, param)
    } else {
      //设备类的单元参数
      return post(`/cumLinks/modify`, param)
    }
  },
  //删除报表参数
  removeCumLinks (id) {
    return post(`/cumLinks/remove`, { fid: id })
  },
  //获取报表
  findCumLinks (param) {
    return post(`/cumLinks/find`, param)
  },




  //新增修改阶段参数
  unitPhaseTagsDefineAdd (param, type) {
    if (type == 1) {
      return post(`/unitPhaseTagsDefine/add`, param)
    } else {
      return post(`/unitPhaseTagsDefine/modify`, param)
    }
  },
  //查询阶段参数列表
  unitPhaseTagsDefineList (param) {
    if (param.field) {
      return post(`/unitPhaseTagsDefine/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/unitPhaseTagsDefine/list?page=${param.page}&size=${param.size}`, param)
    }
  },

  //阶段配置  详情配置 
  phaseTagDefineAdd (param, type) {
    if (type == 1) {
      return post(`/phaseTagDefine/add`, param)
    } else {
      return post(`/phaseTagDefine/modify`, param)
    }
  },
  //查询阶段配置详情列表
  getPhaseTagDefineList (param) {
    if (param.field) {
      return post(`/phaseTagDefine/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/phaseTagDefine/list?page=${param.page}&size=${param.size}`, param)
    }
  },

  // 删除查询阶段配置详情列表
  removePhaseTagDefine (id) {
    return post(`/phaseTagDefine/remove`, { fid: id })
  },
  //查询阶段PLC地址列表
  getAddrPhaseList (param) {
    return post(`/addrPhase/list`, param)
  },
  //查询阶段变量地址列表
  getAddrTagList (param) {
    return post(`/addrTag/list?page=${1}&size=${999999}`, param)
  },
  //查询单元PLC地址列表
  getAddrUnitList (param) {
    return post(`/addrUnit/list`, param)
  },
  //新增原因
  reasAdd (param, type) {
    if (type == 1) {
      return post(`/reas/add`, param)
    } else {
      return post(`/reas/modify`, param)
    }
  },
  getReasList (param) {
    if (param.field) {
      return post(`/reas/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/reas/list?page=${param.page}&size=${param.size}`, param)
    }
  },
  //删除原因
  removeReas (id) {
    return post(`/reas/remove`, { fid: id })
  },


  //新增原因组
  reasGroupAdd (param, type) {
    if (type == 1) {
      return post(`/reasGroup/add`, param)
    } else {
      return post(`/reasGroup/modify`, param)
    }
  },
  //获取原因组列表
  getReasGroupList (param) {
    if (param.field) {
      return post(`/reasGroup/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
    } else {
      return post(`/reasGroup/list?page=${param.page}&size=${param.size}`, param)
    }
  },
  //删除原因组
  removeGroupReas (id) {
    return post(`/reasGroup/remove`, { fid: id })
  },

  //查询设备地址
  addrUnitList (id) {
    return post(`/addrUnit/list`, { fid: id })
  },
  //导出审计追踪
  exportXls (param) {
    return exportXlsx('/hisAuditTrail/exportXls', param)
  },



  // 获得阶段定义列表
  getEnumGroupList (param) {
    return post(`/enumGroup/list?page=${param.page}&size=${param.size}`, param)
  },
  //新增阶段定义
  enumGroupAdd (param, type) {
    if (type == 1) {
      return post(`/enumGroup/add`, param)
    } else {
      return post(`/enumGroup/modify`, param)  //修改阶段定义
    }
  }, //删除阶段定义
  removeenumGroup (id) {
    return post(`/enumGroup/remove`, { fid: id })
  },

  // 获得阶段定义列表
  getEnumsList (param) {
    return post(`/enums/list?page=${param.page}&size=${param.size}`, param)
  },
  // 获得阶段定义列表
  getEnumsListOrderby (param) {
    return post(`/enums/list?page=${param.page}&size=${param.size}&sort=${param.field},${param.order}`, param)
  },
  //新增阶段定义
  enumsAdd (param, type) {
    if (type == 1) {
      return post(`/enums/add`, param)
    } else {
      return post(`/enums/modify`, param)  //修改阶段定义
    }
  }, //删除阶段定义
  removeEnumsGroup (id) {
    return post(`/enums/remove`, { fid: id })
  },

  //服务状态
  getServList (param) {
    return post(`/sysServ/list`, param)
  },
  //服务状态
  operServ (name, oper) {
    return get(`/sysServ/operServ/${name}/${oper}`)
  },
}